home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / WINDOWS / LZAPI.ZIP / CALLBCK.ZIP / CALLBCK.PAS
Encoding:
Pascal/Delphi Source File  |  1995-07-14  |  2.8 KB  |  75 lines

  1. { --------------------------------------------------------------------
  2.  |        C A L L B C K . P A S
  3.  |
  4.  | This is a Simple Pascal-Based Demonstration-Program for LZAPI
  5.  |
  6.  | It will simply copy all you INI-Files into an Archiv in the Temp
  7.  | Directory. But in contrast to SIMPLE.PAS it will tell LZAPI
  8.  | to use the Callback-Technology supported by LZAPI.
  9.  | The only thing it will do is to change Cursor Type every 300 milliseconds.
  10.  |
  11.  | Bernd Herd 9.5.95
  12.  ---------------------------------------------------------------------- }
  13.  
  14. Program Callbck;
  15.  
  16. uses LZAPI, WinProcs, WinTypes, Strings;
  17.  
  18.  
  19. var Ctl              : LACTL;                   { Define the Control Strcture }
  20.     WindowsDirectory : Array[0..144] of char;   { Windows-Directory with our INI-Files }
  21.     TempDirectory    : Array[0..144] of char;   { Directory for Temp-Files }
  22.     p                : Pchar;
  23.     dummy            : TOFSTRUCT;               { For OpenFile }
  24.     err              : LAERR;                   { LZAPI Error Code }
  25.  
  26.  
  27.  
  28.   { ----------- Definitions for Callback ------------------- }
  29.   const Cursors : Array[0..5] of PChar =
  30.                    ( IDC_WAIT, IDC_ARROW, IDC_CROSS, IDC_IBEAM, IDC_ICON, IDC_SIZE );
  31.         Next    : Integer = 0;
  32.         TickCount: LongInt =0 ;
  33.  
  34.   { ----------- Simple Callback-Routine -------------------- }
  35.   function OurCallback(Msg : Integer; lpCtl : LPLACTL) : Integer; export;
  36.   var Now : LongInt;
  37.   Begin
  38.     Now := GetTickCount;                        { Actions in Callbacks should not Depend on Call-Count, but on TIME }
  39.     if (Now-TickCount > 300) then Begin
  40.         TickCount := Now;
  41.         SetCursor(LoadCursor(0, Cursors[Next mod 6]));
  42.         Inc(Next);
  43.     End;
  44.     OurCallback := 0;
  45.   End;
  46.  
  47.  
  48. Begin
  49.   { ------ Windows Directory ------------------------ }
  50.   GetWindowsDirectory( WindowsDirectory, sizeof(WindowsDirectory) );
  51.  
  52.   { ------ Temp-Directory --------------------------- }
  53.   GetTempFileName(#0, 'LZH', 0, TempDirectory);
  54.   OpenFile( TempDirectory, dummy, OF_DELETE);
  55.   strRscan(TempDirectory, '\')[1] := #0;
  56.   strCat  (TempDirectory, 'INIS.ARC');
  57.  
  58.   { ------ Fill Control structure ------------------- }
  59.   FillChar( Ctl, sizeof(Ctl), 0);
  60. {  Ctl.hwndOwner       := ; This Program does not open a Window... normaly you MUST support this! }
  61.   Ctl.lStructSize     := sizeof( Ctl );
  62.   Ctl.lpstrArchivFile := TempDirectory;
  63.   Ctl.lpstrWildcards  := '*.INI';
  64.   Ctl.lpstrPath       := WindowsDirectory;
  65.   Ctl.Flags           := LAF_SHORTNAMES;
  66.   Ctl.lpfnCallback    := OurCallback;
  67.  
  68.   { ------ Perform Actions -------------------------- }
  69.   err := LAAppend( @Ctl );
  70.   MessageBeep(0);
  71.   if (err <> LAE_OK)
  72.       then LAErrMsg(err, @Ctl )
  73.       else MessageBox( 0, 'Hi, this was your Success for Today ;-)', 'SIMPLE.PAS', MB_OK or MB_ICONINFORMATION);
  74. End.
  75.